<include file="public@header"/>
</head>
<body>
    <div class="layui-fluid js-check-wrap">
        <form action="{:url('AdminGoodsAttribute/addPost')}" method="post" name="theForm" class=" js-ajax-form layui-form">
            <div class="layui-card">
                <div class="layui-card-header">{:lang('GOODS_ADMINGOODSATTRIBUTE_ADD')}</div>
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('ATTR_NAME')}</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="post[attr_name]" required placeholder="{:lang('PLEASE_ENTER')}{:lang('ATTR_NAME')}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('LABEL_CAT_ID')}</label>
                        <div class="layui-input-block">
                            <select class="layui-input"  name="post[cat_id]" id="">
                                <option value="0">{:lang('SELECT_PLEASE')}</option>
                                {$goods_type_list}
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('LABEL_ATTR_TYPE')}</label>
                        <div class="layui-input-block">
                            <input type="radio" name="post[attr_type]" value="0" title="{$lang['attr_type_values'][0]}" checked>
                            <input type="radio" name="post[attr_type]" value="1" title="{$lang['attr_type_values'][1]}">
                            <p class="layui-word-aux">{:lang('NOTE_ATTR_TYPE')}</p>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('LABEL_ATTR_INPUT_TYPE')}</label>
                        <div class="layui-input-block">
                            <div class="attr_input_type0 inline-block">
                                <input type="radio" name="post[attr_input_type]" value="0" title="{:lang('TEXT')}" checked>
                            </div>
                            <div class="attr_input_type1 inline-block">
                                <input type="radio" name="post[attr_input_type]" value="1" title="{:lang('SELECT')}">
                            </div>
                            <!-- <label class="radio"><input type="radio" name="attr_input_type" value="2" onclick="radioClicked(0)"/> {:lang('TEXT_AREA')}</label> -->
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('LABEL_ATTR_VALUES')}</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea form-control" name="post[attr_values]" rows="7">{$attr.attr_values}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="goods_type" value="{$goods_type}">
                            <button type="submit" class="layui-btn layui-btn-normal js-ajax-submit">{:lang('ADD')}</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>

<include file="public@footer"/>

<script>
    $(function(){
        radioClicked(0);
    })
    
    $('.attr_input_type0').on('click', '.layui-form-radio', function(){
        radioClicked(0);
    });

    $('.attr_input_type1').on('click', '.layui-form-radio', function(){
        radioClicked(1);
    });

    /**
     * 点击类型按钮时切换选项的禁用状态
     */
    function radioClicked(n)
    {
      document.forms['theForm'].elements["post[attr_values]"].disabled = n > 0 ? false : true;
    }

</script>

